//import utils from '../../common/utils.js';
import router from '@system.router';
//import echarts from 'echarts'
import prompt from '@system.prompt'

//import * as THREE from '../../common/three/build/three.module.js';

//let uniforms,geometry,material,mesh;
//let camera, scene, renderer, labelRenderer;
//let camera = new THREE.PerspectiveCamera( 45, 500 / 500, 1, 500 );
export default {

    data: {
        title: "你好!!!",
        array: [
            {id: 1, name: 'jack', age: 18},
            {id: 2, name: 'tony', age: 18},
        ],
        data1: 'default',
        data2: {
          data3: [1, 2, 3]
        },
        appData: 'localData',
        appVersion:'1.0',
    },

    onInit() {
        this.title = this.$t('strings.world');
        this.appData = this.$app.$def.globalData.appData;
        this.appVersion = this.$app.$def.globalData.appVersion;
        console.info('showData1:' + this.data1);
        console.info('showData3:' + this.data2.data3);
    },
    onShow(){
        const el = this.$refs.gameCanvas;
        const ctx = el.getContext('2d');
        //var renderer = new THREE.WebGLRenderer( { canvas: el, context: ctx } );

        //var ctx = this.$element('gameCanvas').getContext('2d');
        var img = new Image();
        img.src = '/common/food_000.JPG';
        img.onload = function() {
            console.log('Image load success');
            ctx.drawImage(img, 200, 200);
        };
        img.onerror = function() {
            console.log('Image load fail');
        };

        //var renderer = new THREE.WebGLRenderer();
        //renderer.setSize( window.innerWidth, window.innerHeight );
        //renderer.setSize( 500, 500 );
        //document.body.appendChild( renderer.domElement );

        //var camera = new THREE.PerspectiveCamera( 45, 500 / 500, 1, 500 );
//        camera.position.set( 0, 0, 100 );
//        camera.lookAt( 0, 0, 0 );
//
//        var scene = new THREE.Scene();
//        //create a blue LineBasicMaterial
//        var material = new THREE.LineBasicMaterial( { color: 0x0000ff } );
//        var geometry = new THREE.Geometry();
//        geometry.vertices.push(new THREE.Vector3( -10, 0, 0) );
//        geometry.vertices.push(new THREE.Vector3( 0, 10, 0) );
//        geometry.vertices.push(new THREE.Vector3( 10, 0, 0) );
//        var line = new THREE.Line( geometry, material );
//        scene.add( line );
//        renderer.render( scene, camera );
    },
    onRestoreData: function onRestoreData(restoreData) {
        // 收到迁移数据，恢复。
        this.continueAbilityData = restoreData;
    },
    invokeGlobalMethod() {
        this.$app.$def.globalMethod();
    },
    getAppVersion() {
        this.appVersion = this.$app.$def.globalData.appVersion;
    }
}
